package nanocast.apps.creator.modules.mediaWindow.view
{
	import nanocast.apps.creator.modules.mediaWindow.events.MediaSelectionEvent;
	import nanocast.apps.creator.modules.mediaWindow.model.MediaProxy;
	import nanocast.apps.creator.modules.mediaWindow.vo.Media;
	
	import org.osflash.thunderbolt.Logger;
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	public class MediaWindowMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "org.puremvc.as3.apps.flex.mediaTile.modules.mediaWindow.view.MediaWindowMediator";
		public var defaultMedia : String = Media.FLASH_VIDEO;
		
		public function MediaWindowMediator(viewComponent:MediaWindow)
		{
			super(NAME, viewComponent);
		}
		
		override public function onRegister():void
		{
			Logger.info(NAME+ " : onRegister()");
			app.addEventListener(MediaSelectionEvent.CHANGE_SELECTED_MEDIATYPE, mediaSelectionEventListener);
			app.addEventListener(MediaSelectionEvent.REFRESH, mediaSelectionEventListener);
		}
		
		override public function listNotificationInterests():Array
		{
			return [
					MediaProxy.MEDIA_FEED_PARSE_COMPLETE
				];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			switch (notification.getName())
			{
				case MediaProxy.MEDIA_FEED_PARSE_COMPLETE:
					
					//drawMediaTile();
					break;
					
				default:
					Logger.info(NAME+ " : handleNotification() "+ notification.getName());
			}	
		}
		
		private function mediaSelectionEventListener(e:MediaSelectionEvent):void
		{
			Logger.info(NAME+ " : mediaSelectionEventListener() "+ e.type);
			switch	(e.type)
			{
				case MediaSelectionEvent.CHANGE_SELECTED_MEDIATYPE:
					
					break;
				
				case MediaSelectionEvent.REFRESH:

					break;
			}
			
		}
		
		protected function get app():MediaWindow
		{
			return viewComponent as MediaWindow;
		}
		
	}
}